home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Whiteline: delta
/
whiteline CD Series - delta.iso
/
progtool
/
basic
/
gbnckon8
/
test.lst
< prev
Wrap
File List
|
1995-11-25
|
6KB
|
264 lines
REM Originalname: <3DGRAFIK.LST>
' **************************
' * Routinen zur 3D Grafik *
' **************************
'
DIM x(1000),y(1000),z(1000)
DIM xx%(1000),yy%(1000)
DIM x_monitor%(1000),y_monitor%(1000),pkt_entf(1000)
DIM start%(200),anz%(200),farbe%(200),entfernung(200)
'
DIM w(20)
DATA 10,40,30,20
DATA 15,50,12,60
DATA 30,20,20,40
FOR n%=1 TO 9
READ w(n%)
NEXT n%
'
@def_quader(50,-5,0,35,w(7),2)
@def_quader(50,-5,w(7),35,w(8),4)
@def_quader(50,-5,w(7)+w(8),35,w(9),6)
@def_quader(50,50,0,35,w(1),2)
@def_quader(50,50,w(1),35,w(2),4)
@def_quader(50,50,w(1)+w(2),35,w(3),6)
@def_quader(50,110,0,35,w(4),2)
@def_quader(50,110,w(4),35,w(5),4)
@def_quader(50,110,w(4)+w(5),35,w(6),6)
@def_quader(50,180,0,35,w(7),2)
@def_quader(50,180,w(7),35,w(8),4)
@def_quader(50,180,w(7)+w(8),35,w(9),6)
'
' @Def_torte(0,0,0,150,50,0,50,1)
' @Def_torte(30,0,0,150,50,50,120,2)
' @Def_torte(0,0,0,150,50,120,220,3)
' @Def_torte(0,0,0,150,50,220,250,4)
' @Def_torte(0,0,0,150,50,250,300,5)
' @Def_torte(0,0,0,150,50,300,360,6)
'
@zeige_grafik(10000,30)
DO
EXIT IF MOUSEK
LOOP
END
'
PROCEDURE def_quader(x%,y%,z%,breite%,hoehe%,farbe%)
INC fl%
start%(fl%)=pkt%+1
anz%(fl%)=4
farbe%(fl%)=farbe%+1
'
INC pkt%
x(pkt%)=x%
y(pkt%)=y%
z(pkt%)=z%+hoehe%
INC pkt%
x(pkt%)=x%+breite%
y(pkt%)=y%
z(pkt%)=z%+hoehe%
INC pkt%
x(pkt%)=x%+breite%
y(pkt%)=y%+breite%
z(pkt%)=z%+hoehe%
INC pkt%
x(pkt%)=x%
y(pkt%)=y%+breite%
z(pkt%)=z%+hoehe%
' ----- links und rechts
FOR i%=x% TO x%+breite% STEP breite%
INC fl%
start%(fl%)=pkt%+1
anz%(fl%)=4
farbe%(fl%)=farbe%
'
INC pkt%
x(pkt%)=i%
y(pkt%)=y%
z(pkt%)=z%
INC pkt%
x(pkt%)=i%
y(pkt%)=y%+breite%
z(pkt%)=z%
INC pkt%
x(pkt%)=i%
y(pkt%)=y%+breite%
z(pkt%)=z%+hoehe%
INC pkt%
x(pkt%)=i%
y(pkt%)=y%
z(pkt%)=z%+hoehe%
NEXT i%
' ----- vorne und hinten
FOR i%=y% TO y%+breite% STEP breite%
INC fl%
start%(fl%)=pkt%+1
anz%(fl%)=4
farbe%(fl%)=farbe%+2
'
INC pkt%
x(pkt%)=x%
y(pkt%)=i%
z(pkt%)=z%
INC pkt%
x(pkt%)=x%+breite%
y(pkt%)=i%
z(pkt%)=z%
INC pkt%
x(pkt%)=x%+breite%
y(pkt%)=i%
z(pkt%)=z%+hoehe%
INC pkt%
x(pkt%)=x%
y(pkt%)=i%
z(pkt%)=z%+hoehe%
NEXT i%
RETURN
'
PROCEDURE def_torte(x%,y%,z%,radius%,hoehe%,anf_winkel%,end_winkel%,farbe%)
INC fl%
start%(fl%)=pkt%+1
start_%=start%(fl%)
'
INC pkt%
x(pkt%)=x%
y(pkt%)=y%
z(pkt%)=z%+hoehe%
'
alpha%=anf_winkel%
REPEAT
INC pkt%
x(pkt%)=x%+SIN(alpha%/180*PI)*radius%
y(pkt%)=y%+COS(alpha%/180*PI)*radius%
z(pkt%)=z%+hoehe%
alpha%=(INT(alpha%/10)+1)*10
UNTIL alpha%>=end_winkel%
alpha%=end_winkel%
INC pkt%
x(pkt%)=x%+SIN(alpha%/180*PI)*radius%
y(pkt%)=y%+COS(alpha%/180*PI)*radius%
z(pkt%)=z%+hoehe%
'
anz%(fl%)=pkt%-start%(fl%)+1
anz_%=anz%(fl%)
farbe%(fl%)=farbe%
FOR i%=start_% TO start_%+anz_%-1
INC fl%
start%(fl%)=pkt%+1
anz%(fl%)=4
farbe%(fl%)=farbe%+1
'
INC pkt%
x(pkt%)=x(i%)
y(pkt%)=y(i%)
z(pkt%)=z%
'
INC pkt%
x(pkt%)=x(i%)
y(pkt%)=y(i%)
z(pkt%)=z%+hoehe%
'
IF i%=start_%+anz_%-1
INC pkt%
x(pkt%)=x(start_%)
y(pkt%)=y(start_%)
z(pkt%)=z%+hoehe%
'
INC pkt%
x(pkt%)=x(start_%)
y(pkt%)=y(start_%)
z(pkt%)=z%
ELSE
INC pkt%
x(pkt%)=x(i%+1)
y(pkt%)=y(i%+1)
z(pkt%)=z%+hoehe%
'
INC pkt%
x(pkt%)=x(i%+1)
y(pkt%)=y(i%+1)
z(pkt%)=z%
ENDIF
'
NEXT i%
RETURN
'
PROCEDURE zeige_grafik(entfernung%,winkel%)
' ##### Z-Achse drehen -> Drehung
cos_drehung=COS(150/180*PI)
sin_drehung=SIN(150/180*PI)
CLR i%
REPEAT
INC i%
x_=x(i%)
x(i%)=cos_drehung*x_-sin_drehung*y(i%)
y(i%)=cos_drehung*y(i%)+sin_drehung*x_
UNTIL i%=pkt%
' ##### X-Achse drehen -> Winkel
cos_winkel=COS(winkel%/180*PI)
sin_winkel=SIN(winkel%/180*PI)
CLR i%
REPEAT
INC i%
y_=y(i%)
y(i%)=cos_winkel*y_-sin_winkel*z(i%)
z(i%)=cos_winkel*z(i%)+sin_winkel*y_
UNTIL i%=pkt%
' ##### X_monitor, Y_monitor berechnen
CLR i%
REPEAT
INC i%
x_monitor%(i%)=(x(i%)*entfernung%)/(entfernung%+y(i%))+320
y_monitor%(i%)=-(z(i%)*entfernung%)/(entfernung%+y(i%))+200
pkt_entf(i%)=SQR(x(i%)^2+(entfernung%+y(i%))^2+z(i%)^2)
UNTIL i%=pkt%
' ##### minimale Entfernung berechnen
CLR i%
REPEAT
INC i%
entfernung(i%)=10000000
FOR j%=start%(i%) TO start%(i%)+anz%(i%)-1
IF pkt_entf(j%)<entfernung(i%)
entfernung(i%)=pkt_entf(j%)
ENDIF
NEXT j%
UNTIL i%=fl%
CLR i%
REPEAT
INC i%
CLR summe
FOR j%=start%(i%) TO start%(i%)+anz%(i%)-1
ADD summe,pkt_entf(j%)
NEXT j%
ADD entfernung(i%),summe/anz%(i%)
UNTIL i%=fl%
' ##### Sortieren nach Entfernung
FOR j%=fl% DOWNTO 1
min=10000000
FOR i%=1 TO j%
IF entfernung(i%)<min
min=entfernung(i%)
index%=i%
ENDIF
NEXT i%
'
SWAP start%(j%),start%(index%)
SWAP anz%(j%),anz%(index%)
SWAP farbe%(j%),farbe%(index%)
SWAP entfernung(j%),entfernung(index%)
'
NEXT j%
' ##### Flächen von hinten nach vorne aufbauen
CLR i%
REPEAT
INC i%
CLR j%
REPEAT
xx%(j%)=x_monitor%(start%(i%)+j%)
yy%(j%)=y_monitor%(start%(i%)+j%)
INC j%
UNTIL j%=anz%(i%)
DEFFILL 1,2,farbe%(i%)
POLYFILL anz%(i%),xx%(),yy%()
UNTIL i%=fl%
RETURN